{"ast":null,"code":"var _jsxFileName = \"/data/messenger.client/src/components/Dialog/index.tsx\",\n  _s = $RefreshSig$();\nimport React from 'react';\nimport { DropDownMenu, Name, UserStatus } from \"../\";\nimport { DialogInput } from \"../../containers\";\nimport { Context } from \"../../index\";\nimport { Messages } from \"../../containers\";\nimport { observer } from \"mobx-react-lite\";\nimport { getOtherUserForNotMultiChat } from \"../../utils/Membership\";\nimport './Dialog.scss';\nimport { jsxDEV as _jsxDEV } from \"react/jsx-dev-runtime\";\nimport { Fragment as _Fragment } from \"react/jsx-dev-runtime\";\nconst Dialog = () => {\n  _s();\n  const {\n    store\n  } = React.useContext(Context);\n  const [chat, setChat] = React.useState();\n  const [otherUser, setOtherUser] = React.useState();\n  React.useEffect(() => {\n    if (store.currentDialog && !store.currentDialog.multiChat && store.currentDialog.membership && store.currentDialog.membership.items.length > 0) {\n      setOtherUser(getOtherUserForNotMultiChat(store, store.currentDialog.membership));\n    }\n    if (store.currentDialog.id) {\n      setChat({\n        ...chat,\n        ...store.currentDialog\n      });\n    }\n    // eslint-disable-next-line react-hooks/exhaustive-deps\n  }, [store.currentDialog]);\n  if (store.getViewedDialogId()) {\n    var _store$currentDialog$, _store$currentDialog$2;\n    return /*#__PURE__*/_jsxDEV(\"div\", {\n      className: \"messenger__dialog\",\n      children: [/*#__PURE__*/_jsxDEV(\"div\", {\n        className: \"messenger__dialog-header\",\n        children: [/*#__PURE__*/_jsxDEV(\"div\", {}, void 0, false, {\n          fileName: _jsxFileName,\n          lineNumber: 42,\n          columnNumber: 21\n        }, this), /*#__PURE__*/_jsxDEV(\"div\", {\n          className: \"messenger__dialog-header-info\",\n          children: [/*#__PURE__*/_jsxDEV(\"p\", {\n            className: \"messenger__dialog-header-name\",\n            children: /*#__PURE__*/_jsxDEV(Name, {\n              user: otherUser,\n              chatName: store.currentDialog.name,\n              multiChat: store.currentDialog.multiChat\n            }, void 0, false, {\n              fileName: _jsxFileName,\n              lineNumber: 45,\n              columnNumber: 29\n            }, this)\n          }, void 0, false, {\n            fileName: _jsxFileName,\n            lineNumber: 44,\n            columnNumber: 25\n          }, this), !store.getCurrentDialog().multiChat && /*#__PURE__*/_jsxDEV(\"div\", {\n            className: \"messenger__dialog-header-status\",\n            children: /*#__PURE__*/_jsxDEV(UserStatus, {\n              status: true\n            }, void 0, false, {\n              fileName: _jsxFileName,\n              lineNumber: 49,\n              columnNumber: 37\n            }, this)\n          }, void 0, false, {\n            fileName: _jsxFileName,\n            lineNumber: 48,\n            columnNumber: 33\n          }, this) || /*#__PURE__*/_jsxDEV(\"div\", {\n            className: \"messenger__dialog-header-countMemberships\",\n            children: ((_store$currentDialog$ = store.currentDialog.membership) === null || _store$currentDialog$ === void 0 ? void 0 : _store$currentDialog$.items) && /*#__PURE__*/_jsxDEV(\"span\", {\n              children: `Участников в диалоге: ${Object.keys((_store$currentDialog$2 = store.currentDialog.membership) === null || _store$currentDialog$2 === void 0 ? void 0 : _store$currentDialog$2.items).length}`\n            }, void 0, false, {\n              fileName: _jsxFileName,\n              lineNumber: 54,\n              columnNumber: 37\n            }, this)\n          }, void 0, false, {\n            fileName: _jsxFileName,\n            lineNumber: 52,\n            columnNumber: 29\n          }, this)]\n        }, void 0, true, {\n          fileName: _jsxFileName,\n          lineNumber: 43,\n          columnNumber: 21\n        }, this), /*#__PURE__*/_jsxDEV(DropDownMenu, {\n          children: /*#__PURE__*/_jsxDEV(_Fragment, {\n            children: [/*#__PURE__*/_jsxDEV(\"button\", {\n              onClick: () => chat && store.deleteChatFromAPI(chat),\n              children: \"\\u0423\\u0434\\u0430\\u043B\\u0438\\u0442\\u044C \\u0434\\u0438\\u0430\\u043B\\u043E\\u0433\"\n            }, void 0, false, {\n              fileName: _jsxFileName,\n              lineNumber: 63,\n              columnNumber: 29\n            }, this), /*#__PURE__*/_jsxDEV(\"button\", {\n              onClick: () => chat && store.deleteChatFromAPI(chat),\n              children: \"\\u0423\\u0434\\u0430\\u043B\\u0438\\u0442\\u044C \\u0434\\u0438\\u0430\\u043B\\u043E\\u0433\"\n            }, void 0, false, {\n              fileName: _jsxFileName,\n              lineNumber: 64,\n              columnNumber: 29\n            }, this)]\n          }, void 0, true)\n        }, void 0, false, {\n          fileName: _jsxFileName,\n          lineNumber: 61,\n          columnNumber: 21\n        }, this)]\n      }, void 0, true, {\n        fileName: _jsxFileName,\n        lineNumber: 41,\n        columnNumber: 17\n      }, this), /*#__PURE__*/_jsxDEV(\"div\", {\n        className: \"messenger__dialog-messages\",\n        children: /*#__PURE__*/_jsxDEV(Messages, {}, void 0, false, {\n          fileName: _jsxFileName,\n          lineNumber: 69,\n          columnNumber: 21\n        }, this)\n      }, void 0, false, {\n        fileName: _jsxFileName,\n        lineNumber: 68,\n        columnNumber: 17\n      }, this), chat && /*#__PURE__*/_jsxDEV(\"div\", {\n        className: \"messenger__dialog-input\",\n        children: /*#__PURE__*/_jsxDEV(DialogInput, {\n          chat: chat\n        }, void 0, false, {\n          fileName: _jsxFileName,\n          lineNumber: 73,\n          columnNumber: 25\n        }, this)\n      }, void 0, false, {\n        fileName: _jsxFileName,\n        lineNumber: 72,\n        columnNumber: 21\n      }, this)]\n    }, void 0, true, {\n      fileName: _jsxFileName,\n      lineNumber: 40,\n      columnNumber: 13\n    }, this);\n  } else {\n    return /*#__PURE__*/_jsxDEV(\"div\", {\n      className: \"messenger__dialog\",\n      children: /*#__PURE__*/_jsxDEV(\"div\", {\n        className: \"messenger__dialog-messages\",\n        children: /*#__PURE__*/_jsxDEV(Messages, {}, void 0, false, {\n          fileName: _jsxFileName,\n          lineNumber: 82,\n          columnNumber: 21\n        }, this)\n      }, void 0, false, {\n        fileName: _jsxFileName,\n        lineNumber: 81,\n        columnNumber: 17\n      }, this)\n    }, void 0, false, {\n      fileName: _jsxFileName,\n      lineNumber: 80,\n      columnNumber: 13\n    }, this);\n  }\n};\n_s(Dialog, \"EXvwghq9jTvag5rJRfiSQF/XXg0=\");\n_c = Dialog;\nexport default _c2 = observer(Dialog);\nvar _c, _c2;\n$RefreshReg$(_c, \"Dialog\");\n$RefreshReg$(_c2, \"%default%\");","map":{"version":3,"names":["React","DropDownMenu","Name","UserStatus","DialogInput","Context","Messages","observer","getOtherUserForNotMultiChat","Dialog","store","useContext","chat","setChat","useState","otherUser","setOtherUser","useEffect","currentDialog","multiChat","membership","items","length","id","getViewedDialogId","name","getCurrentDialog","Object","keys","deleteChatFromAPI"],"sources":["/data/messenger.client/src/components/Dialog/index.tsx"],"sourcesContent":["import React from 'react';\nimport {DropDownMenu, Name, UserStatus} from \"../\";\nimport {DialogInput} from \"../../containers\";\nimport {Context} from \"../../index\";\nimport {Messages} from \"../../containers\";\nimport {observer} from \"mobx-react-lite\";\nimport {UserListItem} from \"../../models/response/UserListItem\";\nimport {getOtherUserForNotMultiChat} from \"../../utils/Membership\";\nimport {ChatsListItem} from \"../../models/response/ChatsListItem\";\nimport './Dialog.scss';\n\nconst Dialog = () => {\n    const {store} = React.useContext(Context);\n    const [chat, setChat] = React.useState<ChatsListItem>();\n    const [otherUser, setOtherUser] = React.useState<UserListItem>();\n\n    React.useEffect(() => {\n\n        if (store.currentDialog! &&\n            !store.currentDialog.multiChat &&\n            store.currentDialog.membership &&\n            store.currentDialog.membership.items.length > 0\n        ) {\n            setOtherUser(\n                getOtherUserForNotMultiChat(store, store.currentDialog.membership)\n            );\n        }\n\n        if (store.currentDialog.id) {\n            setChat({\n                ...chat,\n                ...store.currentDialog\n            });\n        }\n        // eslint-disable-next-line react-hooks/exhaustive-deps\n    }, [store.currentDialog]);\n\n    if (store.getViewedDialogId()!) {\n        return (\n            <div className=\"messenger__dialog\">\n                <div className=\"messenger__dialog-header\">\n                    <div/>\n                    <div className=\"messenger__dialog-header-info\">\n                        <p className=\"messenger__dialog-header-name\">\n                            <Name user={otherUser} chatName={store.currentDialog.name} multiChat={store.currentDialog.multiChat} />\n                        </p>\n                        {(!store.getCurrentDialog().multiChat &&\n                                <div className=\"messenger__dialog-header-status\">\n                                    <UserStatus status={true} />\n                                </div>\n                            ) ||\n                            <div className=\"messenger__dialog-header-countMemberships\">\n                                {store.currentDialog.membership?.items &&\n                                    <span>\n                                    {`Участников в диалоге: ${Object.keys(store.currentDialog.membership?.items).length}`}\n                                </span>\n                                }\n                            </div>\n                        }\n                    </div>\n                    <DropDownMenu children={\n                        <>\n                            <button onClick={() => chat && store.deleteChatFromAPI(chat)}>Удалить диалог</button>\n                            <button onClick={() => chat && store.deleteChatFromAPI(chat)}>Удалить диалог</button>\n                        </>\n                    } />\n                </div>\n                <div className=\"messenger__dialog-messages\">\n                    <Messages />\n                </div>\n                {chat &&\n                    <div className=\"messenger__dialog-input\">\n                        <DialogInput chat={chat} />\n                    </div>\n                }\n            </div>\n        );\n    } else {\n        return (\n            <div className=\"messenger__dialog\">\n                <div className=\"messenger__dialog-messages\">\n                    <Messages />\n                </div>\n            </div>\n        );\n    }\n}\n\nexport default observer(Dialog);"],"mappings":";;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAAQC,YAAY,EAAEC,IAAI,EAAEC,UAAU,QAAO,KAAK;AAClD,SAAQC,WAAW,QAAO,kBAAkB;AAC5C,SAAQC,OAAO,QAAO,aAAa;AACnC,SAAQC,QAAQ,QAAO,kBAAkB;AACzC,SAAQC,QAAQ,QAAO,iBAAiB;AAExC,SAAQC,2BAA2B,QAAO,wBAAwB;AAElE,OAAO,eAAe;AAAC;AAAA;AAEvB,MAAMC,MAAM,GAAG,MAAM;EAAA;EACjB,MAAM;IAACC;EAAK,CAAC,GAAGV,KAAK,CAACW,UAAU,CAACN,OAAO,CAAC;EACzC,MAAM,CAACO,IAAI,EAAEC,OAAO,CAAC,GAAGb,KAAK,CAACc,QAAQ,EAAiB;EACvD,MAAM,CAACC,SAAS,EAAEC,YAAY,CAAC,GAAGhB,KAAK,CAACc,QAAQ,EAAgB;EAEhEd,KAAK,CAACiB,SAAS,CAAC,MAAM;IAElB,IAAIP,KAAK,CAACQ,aAAa,IACnB,CAACR,KAAK,CAACQ,aAAa,CAACC,SAAS,IAC9B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